<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:a4j="http://richfaces.org/a4j" xmlns:a="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich">


	<rich:spacer height="30" />
	<a4j:form>
		<a4j:status>
			<f:facet name="start">
				<h:graphicImage value="/img/spinner.gif" />
			</f:facet>
		</a4j:status>

		<rich:panel>
			<f:facet name="header">
				<h:outputText value="Adding a new event" />
			</f:facet>
			<rich:scrollableDataTable id="carList44"
				selection="#{eventsManage.selection}" value="#{groupsManage.all}"
				var="group">
				<rich:column id="nameDiscCol232">
					<f:facet name="header">
						<h:outputText styleClass="headerText" value="Name" />
					</f:facet>
					<h:outputText value="#{group.name}" />
				</rich:column>
				<rich:column id="descDiscCol22">
					<f:facet name="header">
						<h:outputText styleClass="headerText" value="Description" />
					</f:facet>
					<h:outputText value="#{group.description}" />
				</rich:column>
			</rich:scrollableDataTable>

			<rich:dataTable id="carList3" width="400" rows="10"
				onRowMouseOver="this.style.backgroundColor='#F1F1F1'"
				onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
				value="#{participantsManage.all}" var="participant">
				<rich:column id="nameDiscCol22">
					<f:facet name="header">
						<h:outputText styleClass="headerText" value="Name" />
					</f:facet>
					<h:outputText value="#{participant.name}" />
				</rich:column>
				<rich:column id="descDiscCol22">
					<f:facet name="header">
						<h:outputText styleClass="headerText" value="Description" />
					</f:facet>
					<h:outputText value="#{participant.description}" />
				</rich:column>
				<rich:column id="descEventCol22">
					<f:facet name="header">
						<h:outputText styleClass="headerText" value="To Event" />
					</f:facet>
					<a4j:commandLink value="Add to Event"
						action="#{eventsManage.addToEvent(participant)}"
						reRender="tempevent, probinput" />
				</rich:column>
				<f:facet name="footer">
					<rich:datascroller align="center" />
				</f:facet>
			</rich:dataTable>
			<h:panelGrid columns="2" width="400">
				<h:outputText value="Input Probability: " />
				<h:inputText value="#{eventsManage.tempProb}" id="probinput" />
			</h:panelGrid>
			<rich:dataTable id="tempevent" value="#{eventsManage.tempEvent}"
				var="participant" width="400" rows="10">
				<rich:column>
					<f:facet name="header">
						<h:outputText value="Participant" />
					</f:facet>
					<h:outputText value="#{participant.name}" />
				</rich:column>
				<rich:column>
					<f:facet name="header">
						<h:outputText value="Probability rate" />
					</f:facet>
					<h:outputText value="#{eventsManage.getProb(participant)}" />
				</rich:column>
				<rich:column>
					<f:facet name="header">
						<h:outputText value="Remove?" />
					</f:facet>
					<a4j:commandLink value="Remove"
						action="#{eventsManage.removeFromTemp(participant)}"
						reRender="tempevent, probinput" />
				</rich:column>
				<f:facet name="footer">
					<rich:datascroller align="center" />
				</f:facet>
			</rich:dataTable>
			<h:panelGrid columns="3" width="400">
				<rich:calendar value="#{eventsManage.closingDate}" />
				<a4j:commandButton action="#{eventsManage.cancelEvent}"
					value="Cancel Event" reRender="tempevent, eventsk, probinput" />
				<a4j:commandButton action="#{eventsManage.commitEvent}"
					value="Commit Event" reRender="tempevent, eventsk, probinput" />
			</h:panelGrid>
		</rich:panel>
	</a4j:form>

	<a4j:outputPanel>
		<a4j:form>
			<rich:spacer height="30" />
			<rich:panel>
				<f:facet name="header">
					<h:outputText value="Browsing existing events" />
				</f:facet>
				<rich:dataTable value="#{eventsManage.all}" id="eventsk" rows="10"
					var="event" rendered="#{eventsManage.all.size() > 0}"
					onRowMouseOver="this.style.backgroundColor='#F1F1F1'"
					onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'">
					<rich:column>
						<f:facet name="header">
							<h:outputText styleClass="headerText" value="ID" />
						</f:facet>
						<h:outputText value="#{event.id}" />
					</rich:column>
					<rich:column>
						<f:facet name="header">
							<h:outputText styleClass="headerText" value="Creation date" />
						</f:facet>
						<h:outputText value="#{event.creationDate}" />
					</rich:column>
					<rich:column>
						<f:facet name="header">
							<h:outputText styleClass="headerText" value="Closing date" />
						</f:facet>
						<h:outputText value="#{event.closingDate}" />
					</rich:column>
					<rich:column>
						<f:facet name="header">
							<h:outputText styleClass="headerText" value="Group" />
						</f:facet>
						<h:outputText value="#{event.group.name}" />
					</rich:column>
					<rich:column>
						<f:facet name="header">
							<h:outputText styleClass="headerText" value="Discipline" />
						</f:facet>
						<h:outputText value="#{event.group.discipline.name}" />
					</rich:column>
					<rich:column>
						<f:facet name="header">
							<h:outputText styleClass="headerText" value="Details" />
						</f:facet>
						<a4j:commandLink value="Show Deatils"
							action="#{eventsManage.setCurrentEvent(event)}" reRender="evpar" />
					</rich:column>
					<f:facet name="footer">
						<rich:datascroller align="center" />
					</f:facet>
				</rich:dataTable>

				<rich:dataTable value="#{eventsManage.participants}" id="evpar"
					rows="5" var="entry" width="400"
					onRowMouseOver="this.style.backgroundColor='#F1F1F1'"
					onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'">
					<rich:column>
						<f:facet name="header">
							<h:outputText value="Name" styleClass="headerText" />
						</f:facet>
						<h:outputText value="#{entry.name}" />
					</rich:column>
					<rich:column>
						<f:facet name="header">
							<h:outputText value="Description" styleClass="headerText" />
						</f:facet>
						<h:outputText value="#{entry.description}" />
					</rich:column>
					<rich:column>
						<f:facet name="header">
							<h:outputText value="Rate" styleClass="headerText" />
						</f:facet>
						<h:outputText value="#{eventsManage.getRate(entry)}" />
					</rich:column>
					<rich:column
						rendered="#{eventsManage.currentEvent != null and eventsManage.currentEvent.winner == null}">
						<f:facet name="header">
							<h:outputText value="Winner" />
						</f:facet>
						<a4j:commandLink value="set" action="#{eventsManage.setAsWinner(entry)}" reRender="winnertext"/>
					</rich:column>
					<f:facet name="footer">
						<rich:datascroller align="center" />
					</f:facet>
				</rich:dataTable>
				<h:outputText
					value="Winner: #{eventsManage.currentEvent.winner.name}" id="winnertext"
					rendered="#{eventsManage.currentEvent != null and eventsManage.currentEvent.winner != null}" />
			</rich:panel>
		</a4j:form>
	</a4j:outputPanel>
</ui:composition>